home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Interactive Media Design Review 1999
/
Interactive Media Design Review 1999.iso
/
pc
/
Demos
/
Herois
/
Codigo.Cst
/
00072_Script_PalavrasGenerico
< prev
next >
Wrap
Text File
|
1999-03-19
|
10KB
|
344 lines
property sprPaginas -- Sprite que contem lista de arquivos/paginas
property sprIndicadorScroll -- Sprite com botao de scroll
property memMe -- Membro que contem lista
property strPalavraDigitada -- Palavra digitada
-- Palavras selecionadas (clicadas)
property intIndicePalavras, intPalavraSelecionada
-- Ataualizacao da lista
property bBuscando
property intScroll, intLinhas
property strLista, intNovasLinhas
property timeUltimaAtualizacao
-- Descricao da Behavior
on getBehaviorDescription
return "Gerencia lista de palavras"
end
on getPropertyDescriptionList
set p_list = [ ¼
#sprPaginas: [ #comment: "Sprite que contem lista de paginas", ¼
#format: #integer, ¼
#default: "" ], ¼
#sprIndicadorScroll: [ #comment: "Sprite do indicador de scroll", ¼
#format: #integer, ¼
#default: "" ] ¼
]
return p_list
end
-- Inicializacao do sprite
on beginSprite me
put the member of sprite (the spriteNum of me) into memMe
put 0 into intScroll
put 0 into intLinhas
set the text of field memMe to ""
put 0 into intPalavraSelecionada
set strLista to ""
set intNovasLinhas to 0
set bBuscando to false
end
-- Mensagens de scroll
on scrollingUp me
if intScroll > 0 then
scrollByLine member memMe, -1
put intScroll - 1 into intScroll
sendSprite(sprIndicadorScroll, #move, intScroll * 10000 / (intLinhas-1))
end if
updateStage
set tmp = the timer + 20
repeat while the mouseDown
if intScroll > 0 and the timer - tmp > 6 then
scrollByLine member memMe, -1
put intScroll - 1 into intScroll
sendSprite(sprIndicadorScroll, #move, intScroll * 10000 / (intLinhas-1))
updateStage
set tmp = the timer
end if
sendAllSprites(#idleSprite)
end repeat
end
on scrollingDown me
if intLinhas > 5 and intScroll < intLinhas - 1 then
scrollByLine member memMe, +1
put 1 + intScroll into intScroll
sendSprite(sprIndicadorScroll, #move, intScroll * 10000 / (intLinhas-1))
updateStage
end if
set tmp = the timer + 20
repeat while the mouseDown
if intLinhas > 5 and intScroll < intLinhas - 1 and the timer - tmp > 6 then
scrollByLine member memMe, +1
put 1 + intScroll into intScroll
sendSprite(sprIndicadorScroll, #move, intScroll * 10000 / (intLinhas-1))
updateStage
set tmp = the timer
end if
sendAllSprites(#idleSprite)
end repeat
end
on scrollPaginaCima
if intLinhas <= 5 then return
put intScroll-5 into tmp
if tmp < 0 then put 0 into tmp
scrollByLine member memMe, tmp - intScroll
put tmp into intScroll
sendSprite(sprIndicadorScroll, #move, intScroll*10000/(intLinhas-1))
updateStage
end
on scrollPaginaBaixo
if intLinhas <= 5 then return
put intScroll+5 into tmp
if tmp > intLinhas - 1 then put intLinhas - 1 into tmp
scrollByLine member memMe, tmp - intScroll
put tmp into intScroll
sendSprite(sprIndicadorScroll, #move, intScroll*10000/(intLinhas-1))
updateStage
end
on scrollArraste me, posicao
if intLinhas <= 5 then return
put posicao * (intLinhas - 1) / 10000 into tmp
scrollByLine member memMe, tmp - intScroll
put tmp into intScroll
end
on scrollArrasteFim me
if intLinhas <= 5 then
sendSprite(sprIndicadorScroll, #move, 0)
updateStage
end if
end
-------------------------------------------------------------------
-------------------------------------------------------------------
-------------------------------------------------------------------
-- Zera lista
on zera me
put 0 into intScroll
put 0 into intLinhas
put 0 into intPalavraSelecionada
set the text of member memMe to ""
set strLista to ""
set intNovasLinhas to 0
set bBuscando to false
set the foreColor of member memMe to ¼
(the backColor of member "FundoPreto")
set the fontSize of member memMe to¼
the fontSize of member "TipoLetra"
set the font of member memMe to¼
the font of member "TipoLetra"
sendSprite(sprIndicadorScroll, #move, 0)
end
-- Prenche lista com palavras iniciadas com pal
on preenche me, pal
global gPals, gRefs
-- Limpa listas
put 0 into intScroll
put 0 into intLinhas
sendSprite(sprPaginas, #zera)
put "" into strLista
set intNovasLinhas to 0
put [] into intIndicePalavras
put 0 into intPalavraSelecionada
put false into bBuscando
put 0 into intTamanhoLista
sendSprite(sprIndicadorScroll, #move, 0)
-- Guarda o que a pessoa digitou
put pal into strPalavraDigitada
-- Se a pessoa nao digitou nada, volta com as
-- listas vazias
if strPalavraDigitada = "" then
set the text of member memMe to ""
return
end if
-- Prepara busca na base de dados
mSetCriteria(gPals, "canonica", "starts", canoniza(strPalavraDigitada))
mSelect(gPals)
-- Verifica numero de registros para ler (no maximo 12 a principio)
put mSelectCount(gPals) into counter
-- put "PalavrasGenerico: Palavras encontradas: " & counter
if counter > 12 then
put 12 into counter
put true into bBuscando
end if
-- Le registros por (teoricamente) 1 segundo
put the timer into agora
repeat while (counter > 0) and ((the timer) - agora < 100 )
if (strLista <> "") then put RETURN after strLista
-- Le do banco de dados
put mGetField(gPals,"palavra") into newPal
put mGetField(gPals,"palNum") into indice
-- Acerta indice de palavras
put the number of words in newPal into tmp
repeat with i = 1 to tmp
add intIndicePalavras, indice
end repeat
-- Acerta lista
put newPal after strLista
-- Proxima palavra
mGoNext(gPals)
put counter - 1 into counter
end repeat
if counter > 0 then put true into bBuscando
-- Reseta lista de palavras
global eMac
if eMac then
trocaTexto memMe, strLista, (the backColor of member "FundoPreto"),¼
"PalavrasGenerico", "PalavrasGenericoBack"
else
set the foreColor of member memMe to ¼
(the backColor of member "FundoPreto")
set the text of field memMe to strLista
set the foreColor of member memMe to ¼
(the backColor of member "FundoPreto")
end if
set intLinhas = the lineCount of member memMe
put the timer into timeUltimaAtualizacao
-- Atualiza "Stage"
updateStage
end
-- No tempo livre ha duas coisas a serem feitas:
-- . ler sistematicamente o resto dos registros a serem lidos
-- . a cada 100 novos registros ou 3 segundos fazer um "update"
-- na lista de palavras
on idleSprite me
-- Verifica se e' hora de atualizar lista sendo mostrada
if (intNovasLinhas >= 100) or ¼
((intNovasLinhas > 0) and ¼
(the timer - timeUltimaAtualizacao > 300)) then
-- put "PalavrasGenerico: idleSprite # tempo passado=" & ¼
-- the timer - timeUltimaAtualizacao &¼
-- ", novos items=" & intNovasLinhas
-- Membro que contem texto
set the forecolor of member memMe to ¼
(the backColor of member "FundoPreto")
set the text of member memMe to strLista
put the lineCount of member memMe into intLinhas
if intPalavraSelecionada > 0 and¼
intPalavraSelecionada <= count(intIndicePalavras) then
pinta me, intPalavraSelecionada, 3
end if
scrollByLine member memMe, intScroll
set intNovasLinhas to 0
put the timer into timeUltimaAtualizacao
sendSprite(sprIndicadorScroll, #move, ¼
intScroll * 10000 / (intLinhas-1))
updateStage
end if
-- Verifica se tem mais registros para buscar
if bBuscando then
-- Le registros por 1 segundo
put 0 into ret
put 3 into counter
put the timer into agora
-- Le registros por 1 segundo
repeat while (the timer - agora < 100) and (ret = 0) ¼
and (counter > 0)
put mGetField(gPals,"palavra") into newPal
put mGetField(gPals,"palNum") into indice
-- Acerta indice de palavras
put the number of words in newPal into tmp
repeat with i = 1 to tmp
add intIndicePalavras, indice
end repeat
-- Acerta lista
put RETURN & newPal after strLista
put 1 + intNovasLinhas into intNovasLinhas
-- Vai para proximo
put mGoNext(gPals) into ret
put 1 - counter into counter
end repeat
-- Se chegou no final para busca
if ret <> 0 then
put false into bBuscando
put 0 into timeUltimaAtualizacao -- forca atualizacao
end if
end if
end
-- Pinta palavras de indice de uma determinada cor
on pinta me, pal, cor
set the forecolor of word pal of member memMe to cor
return
put count(intIndicePalavras) into max
put getAt(intIndicePalavras, pal) into tmp
if pal < 1 or pal > max then return
repeat while getAt(intIndicePalavras,pal) = tmp
set the forecolor of word pal of member memMe to cor
put pal + 1 into pal
if pal > max then exit repeat
end repeat
end
-- Seleciona palavras e lista na lista de paginas
on mouseUp me
puppetSound 2, "SomCliqueSimples"
put the mouseWord into mw
-- put "PalavrasGenerio: mouseUp # " & mw
if mw < 1 or mw > count(intIndicePalavras) then return
if intPalavraSelecionada > 0 and¼
intPalavraSelecionada <= count(intIndicePalavras) then
-- if the platform contains "Mac" then
set the foreColor of member memMe to ¼
(the backColor of member "FundoPreto")
-- set the text of member memMe to¼
-- the text of member memMe
-- else
-- pinta me, intPalavraSelecionada, ¼
-- (the backColor of member "FundoPreto")
-- end if
end if
put getAt(intIndicePalavras,mw) into tmp
repeat while getAt(intIndicePalavras,mw) = tmp
put mw - 1 into mw
if mw = 0 then exit repeat
end repeat
put mw + 1 into mw
put mw into intPalavraSelecionada
pinta me, intPalavraSelecionada, ¼
(the backColor of member "FundoAzul")
sendSprite(sprPaginas, #preenche,¼
getAt(intIndicePalavras,intPalavraSelecionada) )
end